package com.chenju.javastatic.component.config;

import com.chenju.javastatic.utils.EasyListUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.List;

@Data
@Configuration
@PropertySource("classpath:targetproject.properties")
public class TargetProjectConfig {
    /*Package Setting*/
    private static List<String> packagesStringArray;
    private static List<String> ignorePackagesStringArray;

    /*JarFile Setting*/
    private static List<String> jarPathArray;
    private static List<String> applicationArray;

    @Value("${package.name.startsWith}")
    public void setPackagesStringArray(String prop) {
        TargetProjectConfig.packagesStringArray = EasyListUtils.asArrayList(prop.split(","));
    }

    @Value("${package.name.ignore.fullName}")
    public void setIgnorePackagesStringArray(String prop) {
        TargetProjectConfig.ignorePackagesStringArray = EasyListUtils.asArrayList(prop.split(","));
    }

    public static List<String> getPackagesStringArray() {
        return packagesStringArray;
    }

    public static List<String> getIgnorePackagesStringArray() {
        return ignorePackagesStringArray;
    }


    @Value("${jar.info.jarpath}")
    public void setJarPathArray(String prop) {
        TargetProjectConfig.jarPathArray = EasyListUtils.asArrayList(prop.split(","));
    }

    @Value("${jar.info.application}")
    public void setApplicationArray(String prop) {
        TargetProjectConfig.applicationArray = EasyListUtils.asArrayList(prop.split(","));
    }

    public static List<String> getJarPathArray() {
        return jarPathArray;
    }

    public static List<String> getApplicationArray() {
        return applicationArray;
    }
}
